/*************************************************************************

File:			replication_analysis 
Date:			20 June 2025 

Description:	Replication of analysis in main text 

Note:			All numerical output, including tables shown in the log-file 
				All figures stored on disk as PDF
				
*************************************************************************/

/*

	Main analysis 
	
	- regressions
	- output of Table 2 

*/

* Models

quietly eststo mainEFmsm: ///
	areg lnc /// 
		i.year i.issuearea  lag_austerity  rrpgov_th [pw=w] ///
		if lnc!=. & ln_c_bil!=. & lag_austerity !=., robust absorb(ccode)

quietly eststo mainEFmsm_lag: ///	
	areg lnc /// 
		i.year i.issuearea  lag_austerity  lag_rrpgov_th rrpgov_th  [pw=w] ///
		if lnc!=. & ln_c_bil!=. & lag_austerity !=., robust absorb(ccode)

quietly eststo mainBmsm: /// 	
	areg ln_c_bil /// 
		i.year i.issuearea  lag_austerity  rrpgov_th [pw=w] ///
		if lnc!=. & ln_c_bil!=. & lag_austerity !=., robust absorb(ccode)

quietly eststo mainBmsm_lag: ///
	areg ln_c_bil /// 
		i.year i.issuearea  lag_austerity lag_rrpgov_th rrpgov_th [pw=w] ///
		if lnc!=. & ln_c_bil!=. & lag_austerity !=., robust absorb(ccode)

* On-screen output of Table 2 		
esttab mainEFmsm mainEFmsm_lag mainBmsm  mainBmsm_lag,   ///
	keep(rrpgov_th lag_rrpgov_th _cons ) coeflabel(rrpgov_th "RRP" /// 
	lag_rrpgov_th "lag RRP" _cons Constant) ///
	mgroups("Earmarked funding" "Direct bilateral aid", span pattern(1 0 1 0)) ///
	nodepvar nomtitles ///
	b(2) se(2) star(* 0.10 ** 0.05) stat(r2 F N, star(F) fmt(2 2 0)) ///
	compress note("Robust standard errors in parentheses") modelwidth(10)
	 

	
/*

	Per-sector RRP effect
	
	- Figure 3 
	- Figure 4 

*/	
	
	
* Effects on Earmarked Funding per issue area (Figure 3)

quietly reghdfe lnc i.issuearea#i.rrpgov_th lag_austerity [pw=w] /// 
	if ln_c_bil!=., absorb(ccode year) vce(robust)		

quietly margins, dydx(rrpgov_th) over(issuearea)

marginsplot, recast(scatter) horizontal xline(0) ///
	title("Effect of RRP on earmarked commitments across aid sectors", pos(11)) ///
	ytitle(" ") xtitle("Effect of RRP") xlabel(-1(.5)3) xtick(-1(.25)3, grid)
	
gr export "figure3.pdf", as(pdf) replace 	
		
* Effects on bilateral aid per issue area (Figure 4)		
quietly reghdfe ln_c_bil i.issuearea#i.rrpgov_th lag_austerity [pw=w] ///
	if lnc!=., absorb(ccode year) vce(robust)		

quietly margins, dydx(rrpgov_th) over(issuearea)

marginsplot, recast(scatter) horizontal xline(0) ///
	title("Effect of RRP on bilateral commitments across aid sectors", pos(11) ring(4)) ///
	ytitle("") xtitle("Effect of RRP") xlabel(-1(.5)3) xtick(-1(.25)3, grid)
		
gr export "figure4.pdf", as(pdf) replace 		


/*************************************************************************

End replication of analysis in main tet 

*************************************************************************/
